package love.yuanmengrobot.attendancesystem.servlet;
/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/6/21 18:27
 */

import com.google.gson.Gson;
import love.yuanmengrobot.attendancesystem.dao.ClazzDao;
import love.yuanmengrobot.attendancesystem.entity.Clazz;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

public class ClazzInitServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {

    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String memberid = request.getParameter("memberid");
        ClazzDao clazzDao = new ClazzDao();
        ArrayList<Clazz> list = clazzDao.queryById(memberid);
        Gson gson = new Gson();
        PrintWriter pw = response.getWriter();
        pw.print(gson.toJson(list));
        pw.flush();
        pw.close();

//        request.getRequestDispatcher("myclazz.jsp").forward(request, response);
    }
}
